/***********************************************************************
 * Module:  Mesto.java
 * Author:  Igor Spremo, Milan Stojkov
 * Purpose: Defines the Class Mesto
 ***********************************************************************/

package model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * 
 * @author Igor Spremo, Milan Stojkov
 *
 */

@SuppressWarnings("serial")
public class Mesto implements Serializable {
	
	protected Integer id;
	protected String zipKod;
	protected String nazivMesta;
	protected int verzija;

	protected Collection<Adresa> adrese;
	protected Collection<Faktura> fakture;
	
	

	public Collection<Adresa> getAdrese() {
		if (adrese == null)
			adrese = new HashSet<Adresa>();
		
		return adrese;
	}

	public Iterator<Adresa> getIteratorAdrese() {
		if (adrese == null)
			adrese = new HashSet<Adresa>();
		
		return adrese.iterator();
	}

	public void setAdrese(Collection<Adresa> newAdrese) {
		removeAllAdrese();
		for (Iterator<Adresa> iter = newAdrese.iterator(); iter.hasNext();)
			addAdresa((Adresa) iter.next());
	}

	public void addAdresa(Adresa newAdresa) {
		if (newAdresa == null)
			return;
		if (this.adrese == null)
			this.adrese = new HashSet<Adresa>();
		if (!this.adrese.contains(newAdresa))
			this.adrese.add(newAdresa);
	}

	public void removeAdresa(Adresa oldAdresa) {
		if (oldAdresa == null)
			return;
		if (this.adrese != null)
			if (this.adrese.contains(oldAdresa))
				this.adrese.remove(oldAdresa);
	}

	public void removeAllAdrese() {
		if (adrese != null)
			adrese.clear();
	}

	public Collection<Faktura> getFakture() {
		if (fakture == null)
			fakture = new HashSet<Faktura>();
		
		return fakture;
	}

	public Iterator<Faktura> getIteratorFAKTURA() {
		if (fakture == null)
			fakture = new HashSet<Faktura>();
		
		return fakture.iterator();
	}

	public void setFakture(Collection<Faktura> newFakture) {
		removeAllFakture();
		for (Iterator<Faktura> iter = newFakture.iterator(); iter.hasNext();)
			addFaktura((Faktura) iter.next());
	}

	public void addFaktura(Faktura newFaktura) {
		if (newFaktura == null)
			return;
		if (this.fakture == null)
			this.fakture = new HashSet<Faktura>();
		if (!this.fakture.contains(newFaktura))
			this.fakture.add(newFaktura);
	}

	public void removeFaktura(Faktura oldFaktura) {
		if (oldFaktura == null)
			return;
		if (this.fakture != null)
			if (this.fakture.contains(oldFaktura))
				this.fakture.remove(oldFaktura);
	}

	public void removeAllFakture() {
		if (fakture != null)
			fakture.clear();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getZipKod() {
		return zipKod;
	}

	public void setZipKod(String zipKod) {
		this.zipKod = zipKod;
	}

	public String getNazivMesta() {
		return nazivMesta;
	}

	public void setNazivMesta(String nazivMesta) {
		this.nazivMesta = nazivMesta;
	}

	public int getVerzija() {
		return verzija;
	}

	public void setVerzija(int verzija) {
		this.verzija = verzija;
	}

}